package j2025.j03;

/**
 * @Author 猫大仙
 */
public class j0307 {
    public int maxSubArray(int[] nums) {
        int ret = Integer.MIN_VALUE;
        int n = nums.length;
        int[] dp = new int[n+1];
        dp[0] = 0;
        for (int i = 1; i <= n; i++) {
            dp[i] = Math.max(dp[i-1]+nums[i-1],nums[i-1]);
            ret = Math.max(ret,dp[i]);
        }
        return ret;
    }
}
